/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.yuecai.modules.yc_coupon.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
import java.sql.Timestamp;

/**
* @website https://el-admin.vip
* @description /
* @author dm
* @date 2020-07-21
**/
@Entity
@Data
@Table(name="yc_coupon")
public class YcCoupon implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "主键")
    private Long id;

    @Column(name = "coupon_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠券类型 关联字典表 COUPON_TYPE  1:全品类 2:限品类 3:限制品牌")
    private Integer couponType;

    @Column(name = "conditions_id")
    @ApiModelProperty(value = "条件ID coupon_type 为 2 3 时有值")
    private Long conditionsId;

    @Column(name = "condition_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "条件的类型，0为金额，1为件数")
    private Integer conditionType;

    @Column(name = "conditions",nullable = false)
    @NotNull
    @ApiModelProperty(value = "条件")
    private BigDecimal conditions;

    @Column(name = "discount_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠的类型，0为金额，1为折扣")
    private Integer discountType;

    @Column(name = "discount",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优惠")
    private BigDecimal discount;

    @Column(name = "expire_date")
    @ApiModelProperty(value = "领取截止时间")
    private Timestamp expireDate;

    @Column(name = "expire_days")
    @ApiModelProperty(value = "领取后失效的天数")
    private Integer expireDays;

    @Column(name = "coupon_name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "优惠券名称")
    private String couponName;

    @Column(name = "circulation",nullable = false)
    @NotNull
    @ApiModelProperty(value = "发行量，-1为无限制")
    private Integer circulation;

    @Column(name = "astrict")
    @ApiModelProperty(value = "每人限制领取几张")
    private Integer astrict;

    @Column(name = "shopping_for_enough")
    @ApiModelProperty(value = "购物满多少可得 获取方式为购物赠券有值")
    private BigDecimal shoppingForEnough;

    @Column(name = "way",nullable = false)
    @NotNull
    @ApiModelProperty(value = "获取方式 1注册赠券 2 购物赠券赠送 3主动领取 4后台发送 5老邀新  6 新用户首单")
    private Integer way;

    @Column(name = "start_date")
    @ApiModelProperty(value = "开始时间")
    private Timestamp startDate;

    @Column(name = "shopping_price")
    @ApiModelProperty(value = "获取条件购买满多少钱 获取方式为2时有值")
    private BigDecimal shoppingPrice;

    @Column(name = "allowance")
    @ApiModelProperty(value = "发行多少张")
    private int allowance;

    @Column(name = "remarks")
    @ApiModelProperty(value = "备注")
    private String remarks;

    public void copy(YcCoupon source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}